package com.wodsy.phoenix.dataobject.goodsc.model;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;

/**
 * TbGoodsSku entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "tb_goods_sku", catalog = "goodsc")
public class GoodsSku implements java.io.Serializable {

	// Fields
	private static final long serialVersionUID = 1L;
	
	private Integer id;
	private Integer listPrice;			//商品市场销售价格
	private Integer salePrice;			//实际销售价格
	private Boolean onSale;				//是否在销售： 0 不在销售  1 在销售
	private Date addTime;			//添加时间
	private Date updateTime;		//最后一次修改的时间
	
	private Set<GoodsSkuAttr> goodsSkuAttr = new HashSet<>(2);
	private GoodsInventory goodsInventory = new GoodsInventory();
	
	
	// Constructors

	/** default constructor */
	public GoodsSku() {
	}

	/** minimal constructor Integer goodsId,*/
	public GoodsSku( Integer salePrice, Boolean onSale,
			Date addTime) {
		this.salePrice = salePrice;
		this.onSale = onSale;
		this.addTime = addTime;
	}

	/** full constructor */
	public GoodsSku( Integer listPrice, Integer salePrice,
			Boolean onSale, Date addTime, Date updateTime) {
		this.listPrice = listPrice;
		this.salePrice = salePrice;
		this.onSale = onSale;
		this.addTime = addTime;
		this.updateTime = updateTime;
	}

	// Property accessors
	@GenericGenerator(name = "generator", strategy = "increment")
	@Id
	@GeneratedValue(generator = "generator")
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Column(name = "list_price")
	public Integer getListPrice() {
		return this.listPrice;
	}

	public void setListPrice(Integer listPrice) {
		this.listPrice = listPrice;
	}

	@Column(name = "sale_price", nullable = false)
	public Integer getSalePrice() {
		return this.salePrice;
	}

	public void setSalePrice(Integer salePrice) {
		this.salePrice = salePrice;
	}

	@Column(name = "on_sale", nullable = false)
	public Boolean getOnSale() {
		return this.onSale;
	}

	public void setOnSale(Boolean onSale) {
		this.onSale = onSale;
	}

	@Column(name = "add_time", nullable = false, length = 19)
	public Date getAddTime() {
		return this.addTime;
	}

	public void setAddTime(Date addTime) {
		this.addTime = addTime;
	}

	@Column(name = "update_time", length = 19)
	public Date getUpdateTime() {
		return this.updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	@OneToMany(fetch=FetchType.EAGER,cascade={CascadeType.ALL})
	@JoinColumn(name="sku_id")
	public Set<GoodsSkuAttr> getGoodsSkuAttr() {
		return goodsSkuAttr;
	}

	public void setGoodsSkuAttr(Set<GoodsSkuAttr> goodsSkuAttr) {
		this.goodsSkuAttr = goodsSkuAttr;
	}

	@OneToOne(fetch=FetchType.EAGER,cascade={CascadeType.ALL},mappedBy="goodsSku")
	public GoodsInventory getGoodsInventory() {
		return goodsInventory;
	}

	public void setGoodsInventory(GoodsInventory goodsInventory) {
		this.goodsInventory = goodsInventory;
	}
	
}